====== Core Toolchain Setup ======
    for MIOS application development on Windows

\\
\\
**The technical jargon:**\\
This is //Part ONE of THREE// in a walkthrough on the process of developing [[MIOS]] Applications, primarily in C, [[how_to_mix_c_and_asm|but also in ASM]] utilising the [[http://www.ucapps.de/mios_c.html|MIOS C Wrapper]] or Microchip's [[http://www.microchip.com/|MPASM]]. The platform used will be [[http://www.codeblocks.org|Code::Blocks IDE]] on[[http://microsoft.com/windowsxp|Microsoft Windows XP]], and the applications will be built for both [[mios_c_simulator_-_debugger|AC-Sim (AudioCommander's C Simulator)]] compiled with [[http://gcc.gnu.org|GCC]] for [[http://www.mingw.org|MinGW]], and for the [[home#mbhpmidibox_hardware_platform|MIDIBox Hardware Platform (MBHP)]] compiled for [[http://www.microchip.com/stellent/idcplg?IdcService=SS_GET_PAGE&nodeId=2042&param=en020453&pageId=74|PIC18F]] with [[http://sourceforge.net/projects/sdcc|SDCC]], assembled with [[http://sourceforge.net/projects/gputils|GPUtils]], using [[http://www.activestate.com|ActiveState]] [[http://www.activestate.com/Products/ActivePerl/?mp=1|ActivePerl]] to generate, and parse files for, the DOS-Console-based make batch file scripts, and [[http://miosstudio.midibox.org|MIOS Studio]] will be used for debugging on MBHP.

**Enough of that.**\\
Please don't be put off by all that mumbo jumbo. If you're totally newbie then this document is also for you :) I've included everything you need to do, step-by-step, for everything except for actually coding the app. I hope this will not only make it easier for newbies to get started, but for ASM coders like myself to transfer their skills into C development (which seems to be the future of MIOS, and is an excellent rapid prototyping method) or as a reference point for the experienced. In order to do this, I've included as much information as possible, but I have created links to jump through the document for those who don't need all that detail.

I hope you find this document helpful, and that you will feel free to make suggestions or criticism or corrections or any kind of modifications as you see fit :)

\\
\\

====== Required Tools ======

===== Sun Java J2SE =====

Chances are you already have this... I don't recommend upgrading the existing version if you do.
  * [[http://www.java.com/getjava/|Download J2SE]]
  * Install with defaults or whatever meets your requirements. I recommend disabling automatic updates.
\\

===== 7zip =====

This tool is needed to extract compressed files. If you already have winzip or winrar then you won't need this. I recommend the latest version MSI installer for ease of use.
  * [[http://www.7-zip.org/|Download 7zip]]
  * Install the complete application using the defaults
\\



===== ActiveState ActivePerl =====

  * [[http://www.activestate.com/store/download.aspx?prdGUID=81fbce82-6bd5-49bc-a915-08d58c2648ca|Download ActivePerl]]. You want the release called Windows "(x86)", MSI
  * Install using defaults
  * If you are prompted to restart your computer, then do so (yes, now... I know it's annoying!).
\\


==== Environment Variables ====

Normally, the necessary directories are added to your PATH environment variable during the above installations. Sometimes, they aren't. Here's how to check it:

  * Minimise any open windows so that you can see the desktop. 
  * Right-click on 'My Computer', select 'Properties'.
  * Click on the 'Advanced' tab, then click 'Environment Variables'
  * Under either User or System variables, select the variable 'PATH' and click 'Edit'
  * Add these entries if they don't exist (Entries should be separated by semicolons):
    * ;C:\PERL\bin\
\\

====== C Development Tools ======

**The following items are not required if you will only be coding in ASM.** If that's the case, please skip to  Part 2 - [[windows_toolchain_asm_acsim|Extend your toolchain with MinGW to build the AC-Sim DOS C Simulator, or MPASM for ASM coding]]
\\
\\
**If you're going to code in C**, or you're unsure, carry on. You won't break anything. :)
\\
\\


===== GNU PIC Utilities (GPUtils) =====

  * [[https://sourceforge.net/project/showfiles.php?group_id=41924|Download gputils-win32]]. There's only one there by that exact name. Grab the latest.
  * Install the complete application using the 'Full' option.
  * When the installer asks you, click 'Yes' to add the installation directory to the PATH environment variable.
\\



===== Small Device C Compiler (SDCC) =====

  * [[http://sourceforge.net/project/showfiles.php?group_id=599|Download SDCC.]] 2.50 is officially supported or you can [[http://sdcc.sourceforge.net/snap.php#Windows|get the latest snapshot]] if you're more experienced. \\
This is a point of some contention. If you are new, I would recommend 2.50. Some PIC compiler routines have been improved in 2.6.0+ so this may be beneficial, but the snapshot builds can also cause perfectly good code to fail. If you get the snapshot, search for "i586-mingw32msvc-setup" and take the file at the top of the list.\\
  * Either way, I recommend you download the relevant documentation for SDCC - it will come in handy later! If you are getting v2.50, you can get the manual[[http://sdcc.sourceforge.net/doc/sdccman.pdf|here]], but it should be installed with SDCC. If you are getting the snapshot build, search for "docs" and take the .zip file at the top of the list.

  * Install using defaults (Note that this installs the PDF doc as well which can be very useful)
\\

==== Environment Variables ====

Normally, the necessary directories are added to your PATH environment variable during the above installations. Sometimes, they aren't. Here's how to check it:

  * Minimise any open windows so that you can see the desktop. 
  * Right-click on 'My Computer', select 'Properties'.
  * Click on the 'Advanced' tab, then click 'Environment Variables'
  * Under either User or System variables, select the variable 'PATH' and click 'Edit'
  * Add these entries if they don't exist (Entries should be separated by semicolons):
    * ;C:\Program Files\gputils\bin
    * ;C:\Program Files\SDCC\bin

\\
\\
\\

====== Part 1 Complete ======

**If you made it this far**, you've actually done enough. You can code C apps in notepad.exe, run make.bat to create your app, and then upload it.\\

If you'd like to have a more advanced tool set in your hands, please read on to  Part 2 - [[windows_toolchain_asm_acsim|Extend your toolchain with MinGW to build the AC-Sim DOS C Simulator, or MPASM for ASM coding]]
\\
\\